package es.unileon.prg2.censo.composite;

/**
 * @author Manuel Molinos Crespo, Adrian Campazas Vega, Alberto Castro Delgado, Pedro Alvarez Alvarez, Adrian Cabello Galvan, Jose Alvaro Fernandez Alvarez
 *
 */

import java.util.ArrayList;

import es.unileon.prg2.censo.exception.CensoException;
import es.unileon.prg2.censo.handler.Handler;
import es.unileon.prg2.censo.iterator.Iterador;
import es.unileon.prg2.censo.iterator.TreeIterator;


public interface Component {
	
	/**
	 * 
	 * Method used to find one component of the list.
	 * @param id The ID of the component looked for
	 * @return The component looked for
	 */
	Component search(Handler id);
	
	/**
	 * 
	 * Method used to delete components of the list.
	 * @param id The ID of the components of the list
	 * @return If the component has been removed return true else return false
	 * @throws CensoException
	 */
	boolean delete(Component id) throws CensoException;
	
	/**
	 * 
	 * Method used to add components of the list.
	 * @param creation The ID of the components of the list
	 * @return If the component has been add return true else return false
	 * @throws CensoException
	 */
	boolean add(Component creation) throws CensoException;
	
	/**
	 * 
	 * Method used to return the type of component.
	 * @return The type of component specific
	 */
	String getLevel();
	
	/**
	 * 
	 * Method used to return the number of components of the list.
	 * @return The number of total components of the list
	 * @throws CensoException
	 */
	int size() throws CensoException;
	
	/**
	 * 
	 * Method used to return the ID of the component.
	 * @return ID of this component 
	 */
	Handler getId();
	
	/**
	 * 
	 * Method used for converting to String the component.
	 * @return String with the name and type of the component
	 */
	String toString();
	
	/**
	 * 
	 * Method used to know if the actual component is a composite or not.
	 * @return null if the component isn't a composite or if it's a composite return this composite
	 */
	Composite getComposite();
	
	/**
	 * 
	 * Method used to know the age of this citizen.
	 * @return The age of the citizen
	 */
	int getAge();
	
	/**
	 * Method used to created an Iterator
	 * 
	 * @param args
	 *            String with type that you want filter and two Strings with the
	 *            ages between you want. Example:
	 *            createIterator("citizens","18","20");
	 * @return The Iterator created before
	 * @throws CensoException
	 */
	Iterador createIterator(int age, int age2) throws CensoException;
	
	/**
	 * 
	 * Method used to return the ArrayList with the childrens of this component
	 * @return ArrayList with the childrens of the component specific
	 */
	ArrayList<Component> getChildren();
	
	/**
	 * Method used to created an Iterator
	 * @return The Iterator created before
	 */
	Iterador createIterator() throws CensoException;
}
